home *** CD-ROM | disk | FTP | other *** search
/ Delphi Magazine Collection 2001 / Delphi Magazine Collection 20001 (2001).iso / DISKS / Issue31 / construc / WORDLIST.DPR < prev    next >
Encoding:
Text File  |  1998-02-06  |  1.1 KB  |  58 lines

  1. {$A+,B-,D-,E-,F-,G-,I-,L-,N-,O-,P-,Q-,R-,S+,T-,V+,X+}
  2. {$APPTYPE CONSOLE}
  3. program WordList;
  4. { Use this program on index.bob generated by index.dpr from issue #30 }
  5. const
  6.   IdentSet = ['A'..'Z','a'..'z',''''];
  7.  
  8. const
  9.   MaxPage = 255;
  10.  
  11. type
  12.   TNumPage = 0..MaxPage; { max number of webpages in site }
  13.  
  14. const
  15.   MaxKeyword = 31-8;
  16.  
  17. type
  18.   TKeyword = String[MaxKeyword];
  19.   TPageSet = Set of TNumPage;
  20.  
  21. type
  22.   TNode = record
  23.     Keyword: TKeyword; { 32 bytes }
  24.     URLs: TPageSet;    { 32 bytes }
  25.   end {TNode};
  26.  
  27. type
  28.   TIndexFile = File of TNode;
  29.  
  30. var
  31.  IndexFile: TIndexFile;
  32.  Words,Skipped,i: Integer;
  33.  OK: Boolean;
  34.  Node: TNode;
  35.  
  36. begin
  37.   Words := 0;
  38.   Skipped := 0;
  39.   Assign(IndexFile,'index.bob');
  40.   Reset(IndexFile);
  41.   while not eof(IndexFile) do
  42.   begin
  43.     read(IndexFile,Node);
  44.     OK := Node.Keyword[1] in IdentSet;
  45.     for i:=2 to Length(Node.Keyword) do
  46.       OK := OK and (Node.Keyword[i] in IdentSet);
  47.     if OK then
  48.     begin
  49.       write(Node.Keyword,' ');
  50.       Inc(Words)
  51.     end
  52.     else Inc(Skipped)
  53.   end;
  54.   Close(IndexFile);
  55.   writeln;
  56.   writeln(Words,' words (',Skipped,' skipped).')
  57. end.
  58.